package ioProcessor;
/*
 * version 1 by Bush 
 */

import entities.Section;
import entities.Staff;
import entities.Course;

public class CourseInputProcessor
{
	public void processCourseData(String line)
	{
		//split the string
		String[] datas=line.split("\t");
		String courseCode=datas[0];
		String LecOrTut=datas[1];
		String sectionId=datas[0]+"_"+datas[1];
		int size=Integer.parseInt(datas[2]);
		int duration=Integer.parseInt(datas[3]);
		String staffId=datas[4];
		
		//add section information
		new Section(sectionId,size,duration,staffId);
		
		//add course information
		Course theCourse=Course.getCourseByCode(courseCode);
		try {
			if (theCourse==null)
			{
				String [] program=null;
				theCourse=new Course(courseCode,program);
			}
			if (LecOrTut.charAt(0)=='T')
				theCourse.addTutorial(sectionId);
			else
				theCourse.addLecture(sectionId);
			
		} catch(Exception e) {
	
		}
		//add staff information
		Staff theStaff=Staff.getStaffById(staffId);
		if(theStaff == null)
			theStaff = new Staff(staffId);
		theStaff.addNewSection(sectionId);
	}
}